package leetcode.part1;

import org.junit.Test;

public class S10 {
    public int jump(int[] nums) {
        int step=0;
        int width=0;
        int maxPosition=0;
        for (int i = 0; i < nums.length-1; i++) {
            maxPosition=Math.max(maxPosition,nums[i]+i);
            if (i==width){
                width=maxPosition;
                step++;
            }


        }
        return step;

    }

   @Test
    public void test(){
       int[] nums={2,3,0,1,4};

       System.out.println(jump(nums));
   }
}
